package com.army.cheatsheets.slice;

import com.army.cheatsheets.ResourceTable;
import com.army.cheatsheets.adapter.ItemProvider;
import com.army.cheatsheets.databean.Item;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.ListContainer;

import java.util.ArrayList;
import java.util.List;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        List<Item> list = getData();

        ItemProvider itemProvider = new ItemProvider(list, this);

        ListContainer listContainer = (ListContainer) findComponentById(ResourceTable.Id_list_container);
        listContainer.setItemProvider(itemProvider);
    }

    private List<Item> getData() {
        List<Item> list = new ArrayList<>();
        Item item1 = new Item("category", "昨日", "");
        Item item11 = new Item("standard", "学习", "12:00");
        Item item12 = new Item("standard", "听书", "18:00");
        list.add(item1);
        list.add(item11);
        list.add(item12);

        Item item2 = new Item("category", "今日", "");
        Item item21 = new Item("standard", "拿/获取", "12:30");
        Item item22 = new Item("standard", "放学", "16:00");
        list.add(item2);
        list.add(item21);
        list.add(item22);

        Item item3 = new Item("category", "明天", "");
        Item item31 = new Item("standard", "英语作业", "10:30");
        Item item32 = new Item("standard", "逛街", "16:00");
        list.add(item3);
        list.add(item31);
        list.add(item32);

        return list;
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
